package cn.wp.user.controller;

import cn.wp.basic.util.AjaxResult;
import cn.wp.user.domain.LoginInfo;
import cn.wp.user.service.ILoginInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录接口
 */
@RestController
public class LoginInfoController {

    @Autowired
    private ILoginInfoService loginInfoService;

    /**
     * 登录验证
     * @param loginInfo
     * @return
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginInfo loginInfo){
        try {
            return loginInfoService.login(loginInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMsg(e.getMessage());
        }
    }
}
